import pygame


class Settings:
    """存储游戏《外星人入侵》中所有设置的类"""
    # 设置开火常量
    FIRE_EVENT = pygame.USEREVENT

    def __init__(self):
        """初始化游戏设置"""
        # 设置屏幕
        self.screen_width = 1600
        self.screen_height = 900
        self.bg_color = (100, 100, 100)

        # 飞船设置
        self.ship_speed = 2
        self.ship_limit = 3

        # 设置子弹
        self.bullet_speed = 3
        self.bullet_width = 3
        self.bullet_hight = 15
        self.bullet_color = (255, 0, 0)
        self.bullets_allowed = 10

        # 外星人设置
        self.alien_speed = 1.0
        self.fleet_drop_speed = 10
        # 1表示向右移动，-1表示想左移动
        self.fleet_direction = 1
        # 分数
        self.alien_points = 10

        """加快游戏节奏"""
        # 提高外星人速度
        self.speedup_scale = 1.3
        # 提高得分
        self.score_scale = 1.5
        self.initialize_dynamic_settings()

    def initialize_dynamic_settings(self):
        """初始化随游戏进行而变化的设置"""
        self.ship_speed = 2.0
        self.bullet_speed = 3
        self.alien_speed = 1.0
        self.alien_points = 10
        # 1表示向右移动，-1表示想左移动
        self.fleet_direction = 1

    def increase_speed(self):
        """提高速度设置"""
        self.ship_speed *= self.speedup_scale
        self.bullet_speed *= self.speedup_scale
        self.alien_speed *= self.speedup_scale
        self.alien_points = int(self.alien_points * self.score_scale)
